/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ClasificacionDePizzasToppingClassificationBox.java
 *
 * Created on 11-ene-2010, 20:04:42
 */

package clasificaciondepizzas;

import clasificaciondepizzas.chart.ToppingChart;
import clasificaciondepizzas.classification.EvaluatorTopping;
import org.jfree.chart.ChartPanel;

/**
 *
 * @author Manuel
 */
public class ClasificacionDePizzasToppingClassificationBox extends javax.swing.JDialog {

        /** Creates new form ClasificacionDePizzasSauceClassificationBox */
    public ClasificacionDePizzasToppingClassificationBox(java.awt.Frame parent, double meanH, double standardDeviationH, double meanS, double standardDeviationS) {
        super(parent);
        this.meanH = meanH;
        this.standardDeviationH = standardDeviationH;
        this.meanS = meanS;
        this.standardDeviationS = standardDeviationS;
        initComponents();
        showChart();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        chartInternalFrame = new javax.swing.JInternalFrame();
        meanHWeightLabel = new javax.swing.JLabel();
        meanHWeightComboBox = new javax.swing.JComboBox();
        standardDeviationHWeightLabel = new javax.swing.JLabel();
        standardDeviationHWeightComboBox = new javax.swing.JComboBox();
        meanSWeightLabel = new javax.swing.JLabel();
        meanSWeightComboBox = new javax.swing.JComboBox();
        standardDeviationSWeightLabel = new javax.swing.JLabel();
        standardDeviationSWeightComboBox = new javax.swing.JComboBox();
        toppingTypeLabel = new javax.swing.JLabel();
        appToppingTypeLabel = new javax.swing.JLabel();
        classifyButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        chartInternalFrame.setName("chartInternalFrame"); // NOI18N
        chartInternalFrame.setVisible(true);

        javax.swing.GroupLayout chartInternalFrameLayout = new javax.swing.GroupLayout(chartInternalFrame.getContentPane());
        chartInternalFrame.getContentPane().setLayout(chartInternalFrameLayout);
        chartInternalFrameLayout.setHorizontalGroup(
            chartInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 376, Short.MAX_VALUE)
        );
        chartInternalFrameLayout.setVerticalGroup(
            chartInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 157, Short.MAX_VALUE)
        );

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(clasificaciondepizzas.ClasificacionDePizzasApp.class).getContext().getResourceMap(ClasificacionDePizzasToppingClassificationBox.class);
        meanHWeightLabel.setText(resourceMap.getString("meanHWeightLabel.text")); // NOI18N
        meanHWeightLabel.setName("meanHWeightLabel"); // NOI18N

        meanHWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        meanHWeightComboBox.setName("meanHWeightComboBox"); // NOI18N

        standardDeviationHWeightLabel.setText(resourceMap.getString("standardDeviationHWeightLabel.text")); // NOI18N
        standardDeviationHWeightLabel.setName("standardDeviationHWeightLabel"); // NOI18N

        standardDeviationHWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        standardDeviationHWeightComboBox.setName("standardDeviationHWeightComboBox"); // NOI18N

        meanSWeightLabel.setText(resourceMap.getString("meanSWeightLabel.text")); // NOI18N
        meanSWeightLabel.setName("meanSWeightLabel"); // NOI18N

        meanSWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        meanSWeightComboBox.setName("meanSWeightComboBox"); // NOI18N

        standardDeviationSWeightLabel.setText(resourceMap.getString("standardDeviationSWeightLabel.text")); // NOI18N
        standardDeviationSWeightLabel.setName("standardDeviationSWeightLabel"); // NOI18N

        standardDeviationSWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        standardDeviationSWeightComboBox.setName("standardDeviationSWeightComboBox"); // NOI18N

        toppingTypeLabel.setText(resourceMap.getString("toppingTypeLabel.text")); // NOI18N
        toppingTypeLabel.setName("toppingTypeLabel"); // NOI18N

        appToppingTypeLabel.setText(resourceMap.getString("appToppingTypeLabel.text")); // NOI18N
        appToppingTypeLabel.setName("appToppingTypeLabel"); // NOI18N

        classifyButton.setText(resourceMap.getString("classifyButton.text")); // NOI18N
        classifyButton.setName("classifyButton"); // NOI18N
        classifyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                classifyButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chartInternalFrame)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(toppingTypeLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(appToppingTypeLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 281, Short.MAX_VALUE)
                        .addComponent(classifyButton))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(meanHWeightLabel)
                            .addComponent(meanHWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(standardDeviationHWeightLabel)
                            .addComponent(standardDeviationHWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(meanSWeightLabel)
                            .addComponent(meanSWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(standardDeviationSWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(standardDeviationSWeightLabel))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chartInternalFrame)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(meanHWeightLabel)
                    .addComponent(standardDeviationHWeightLabel)
                    .addComponent(meanSWeightLabel)
                    .addComponent(standardDeviationSWeightLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(meanHWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(standardDeviationHWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(meanSWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(standardDeviationSWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(toppingTypeLabel)
                            .addComponent(appToppingTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(classifyButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void classifyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_classifyButtonActionPerformed
        EvaluatorTopping et = new EvaluatorTopping(meanHWeightComboBox.getSelectedIndex() + 1, standardDeviationHWeightComboBox.getSelectedIndex() + 1, meanSWeightComboBox.getSelectedIndex() + 1, standardDeviationSWeightComboBox.getSelectedIndex() + 1);
        String toppingType = et.pizzaCalculate(meanH, standardDeviationH, meanS, standardDeviationS);
        appToppingTypeLabel.setText(toppingType);
    }//GEN-LAST:event_classifyButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel appToppingTypeLabel;
    private javax.swing.JInternalFrame chartInternalFrame;
    private javax.swing.JButton classifyButton;
    private javax.swing.JComboBox meanHWeightComboBox;
    private javax.swing.JLabel meanHWeightLabel;
    private javax.swing.JComboBox meanSWeightComboBox;
    private javax.swing.JLabel meanSWeightLabel;
    private javax.swing.JComboBox standardDeviationHWeightComboBox;
    private javax.swing.JLabel standardDeviationHWeightLabel;
    private javax.swing.JComboBox standardDeviationSWeightComboBox;
    private javax.swing.JLabel standardDeviationSWeightLabel;
    private javax.swing.JLabel toppingTypeLabel;
    // End of variables declaration//GEN-END:variables
private double meanH;
private double standardDeviationH;
private double meanS;
private double standardDeviationS;

public void showChart() {
        EvaluatorTopping et = new EvaluatorTopping(meanHWeightComboBox.getSelectedIndex() + 1, standardDeviationHWeightComboBox.getSelectedIndex() + 1, meanSWeightComboBox.getSelectedIndex() + 1, standardDeviationSWeightComboBox.getSelectedIndex() + 1);
        String toppingType = et.pizzaCalculate(meanH, standardDeviationH, meanS, standardDeviationS);
        appToppingTypeLabel.setText(toppingType);
        ToppingChart topping = new ToppingChart(meanH, standardDeviationH, meanS, standardDeviationS);
        ChartPanel bpanel = new ChartPanel(topping.getChart());
        bpanel.setVisible(true);
        chartInternalFrame.setContentPane(bpanel);
    }
}
